package com.bjpowernode.crm.workbench.service;

import com.bjpowernode.crm.workbench.domain.Activity;
import com.bjpowernode.crm.workbench.mapper.ActivityMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @Author:luosheng
 * @Date:2023/1/24 19:59
 * @Description:
 */
@Service
public class ActivityServiceImpl implements ActivityService {

    @Autowired
    private ActivityMapper activityMapper;

    @Override
    public int saveCreateActivity(Activity activity) {
        return activityMapper.insertActivity(activity);
    }

    @Override
    public List<Activity> queryActivityByConditionForPage(Map<String, Object> map) {
        return activityMapper.selectActivityByConditionForPage(map);
    }

    @Override
    public int queryCountOfActivityByCondition(Map<String, Object> map) {
        return activityMapper.selectCountOfActivityByCondition(map);
    }

    @Override
    public int deleteActivityByIds(String[] ids) {
        return activityMapper.deleteActivityByIds(ids);
    }

    @Override
    public Activity queryActivityById(String id) {
        return activityMapper.selectActivityById(id);
    }

    @Override
    public int saveEditActivity(Activity activity) {
        return activityMapper.updateActivityByPrimary(activity);
    }

    @Override
    public List<Activity> queryAllActivitys() {
        return activityMapper.selectAllActivitys();
    }

    @Override
    public List<Activity> queryAllById(String[] id) {
        return activityMapper.selectAllById(id);
    }

    @Override
    public int saveCreateActivityByList(List<Activity> activityList) {
        return activityMapper.insertActivityByList(activityList);
    }

    @Override
    public Activity queryActivityForDetailById(String id) {
        return activityMapper.selectActivityForDetailById(id);
    }


    @Override
    @Transactional(readOnly = true)
    public List<Activity> getActivityListByName(String aname) { //通过名称获取市场活动
        List<Activity> aList = activityMapper.getActivityListByName(aname);
        return aList;
    }
    @Override
    @Transactional(readOnly = true)
    public List<Activity> getActivityListByClueId(String clueId) {  //通过关联的线索id获取所有市场活动
        List<Activity> aList = activityMapper.getActivityListByClueId(clueId);
        return aList;
    }
    @Override
    @Transactional(readOnly = true)
    public List<Activity> getActivityListByNameAndNotByClueId(Map<String, Object> map) {    //通过名称但不通过关联的线索id获取市场活动
        List<Activity> aList = activityMapper.getActivityListByNameAndNotByClueId(map);
        return aList;
    }
    @Override
    @Transactional(readOnly = true)
    public List<Activity> getActivityListByContactsId(String contactsId) {  //通过关联的联系人id获取市场活动
        List<Activity> aList = activityMapper.getActivityListByContactsId(contactsId);
        return aList;
    }
}
